package com.example.baselibrary.Utils;

import java.io.ByteArrayOutputStream;

public class HexToString {

    private static String hexString = "0123456789ABCDEFabcdef";

    public static String decode(String bytes) {
        bytes = bytes.toUpperCase();
        ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length() / 2);
        // 将每2位16进制整数组装成一个字节
        for (int i = 0; i < bytes.length(); i += 2)
            baos.write((hexString.indexOf(bytes.charAt(i)) << 4 | hexString.indexOf(bytes.charAt(i + 1))));

        String name = new String(baos.toByteArray());
        return name;
    }
}
